package com.lbn.jfqsc.app.home;

import com.google.gson.Gson;
import com.lbn.baseframe.mvp.BasePresenter;
import com.lbn.baseframe.net.business.RxSubscribe;
import com.lbn.baseframe.utils.L;
import com.lbn.jfqsc.business.bean.Goods;
import com.lbn.jfqsc.business.bean.User;
import com.lbn.jfqsc.net.Host;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 李炳南
 * @date 2017/2/28
 */
public class HomePresenter extends BasePresenter<IHomeView> {


    public void goods(final int page){

        subscribeNetwork(Host.getApi().goodsList(page), new RxSubscribe<List<Goods>>() {
            @Override
            public void next(List<Goods> goods) {
                L.e("UserJson:"+new Gson().toJson(goods));

                if(goods.size()<2){
                    getView().isMore(false);
                }else{
                    getView().isMore(true);
                }

                if(page==1){
                    getView().setData(goods);
                }else{
                    getView().addData(goods);
                }

            }

            @Override
            public void error(Throwable e) {

            }
        });
    }

}
